new Vue({
    el: '#app',
    data() {
        return {
            defaultImage:'',
            value: new Date(),
            tableData: [],
            form: {
                SQLSerialNumber: "P_base_system_login_log",
                PaginationNumber: 1,//页数
                RowAmount: 15,//每页数据条数
                Condition: window.btoa(unescape(encodeURIComponent(getCookie('user')))),
                ExtensionCondition: '',
            },
            total: 0,
            User:{}
        }
    },
    mounted() {
        this.getData();
        this.getList(this.form);
    },
    computed: {
        getDate() {
            return function (str) {
                let time = new Date(str);
                let m = time.getMonth() + 1;
                let d = time.getDate();
                let H = time.getHours();
                let M = time.getMinutes();
                let S = time.getSeconds();
                if (m < 10) {
                    m = "0" + m
                }
                if (d < 10) {
                    d = "0" + d
                }
                if (H < 10) {
                    H = "0" + H
                }
                if (M < 10) {
                    M = "0" + M
                }
                if (S < 10) {
                    S = "0" + S
                }
                const weekInfo = [{
                    id: 0,
                    week: "星期日"
                },
                {
                    id: 1,
                    week: "星期一"
                },
                {
                    id: 2,
                    week: "星期二"
                },
                {
                    id: 3,
                    week: "星期三"
                },
                {
                    id: 4,
                    week: "星期四"
                },
                {
                    id: 5,
                    week: "星期五"
                },
                {
                    id: 6,
                    week: "星期六"
                }]
                return (time.getFullYear()) + "年" + m + "月" + d + "日" + " " + H + ':' + M + ':' + S + ' 登录 ( ' + weekInfo.find(i => i.id === time.getDay()).week + ' )';
            }
        }
    },
    methods: {
        getData() {
            const that = this
            $.ajax({
                headers: requestHeaders(),
                type: 'POST',
                url: `${BASE_URL2}/generalBusiness/generalQueryBySQLSerialNumber`,
                data: {
                    SQLSerialNumber: 'A_base_system_user_info',
                    Condition: window.btoa(unescape(encodeURIComponent(getCookie('user')))),
                    ExtensionCondition:'',
                },
                success: function (Result) {
                    if (Result.length == 1) {
                        that.User = Result[0];
                        console.log(Result[0]);
                    }
                },
                complete: function (XMLHttpRequest) {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            });
        },
        getList(data) {
            const that = this
            $.ajax({
                headers: requestHeaders(),
                type: 'POST',
                url: `${BASE_URL2}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
                data,
                success: function (Result) {
                    that.tableData = Result.Rows;
                    that.total = Result.TotalRows;
                },
                complete: function (XMLHttpRequest) {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            });
        },
        handleSizeChange(val) {
            this.form.PaginationNumber = 1;
            this.form.RowAmount = val;
            this.getList(this.form)
        },
        handleCurrentChange(val) {
            this.form.PaginationNumber = val;
            this.getList(this.form)
        },
    }
})